import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False

regions = ['华北', '华南', '东北', '西北', '西南', '华东']
sales = [2354, 1902, 3524, 2698, 2896, 2563]
growth_rates = [12, 25, 16, 21, 18, 25]

plt.figure(figsize=(10, 6))

bars = plt.bar(regions, sales, color='skyblue')

for bar in bars:
    height = bar.get_height()
    plt.text(bar.get_x() + bar.get_width() / 2., height, f'{height}', ha='center', va='bottom', fontsize=10)

for i, rate in enumerate(growth_rates):
    plt.scatter(i, sales[i] + 500, color='red', s=400)
    plt.text(i, sales[i] + 500, f'{rate}%', ha='center', va='center', color='white', fontsize=10)

plt.title('各区域销量及同比去年增长率')
plt.xlabel('区域')
plt.ylabel('销量')

#plt.savefig('D:/python charm/01/可视化/第二章/图片/柱形图.png')

plt.show()